Procedure-Related Statements Defining a procedure -------------------- FUNCTION... END FUNCTION Marks the beginning and end, respectively, of a FUNCTION procedure. SUB...END SUB Marks the beginning and end, respectively, of a SUB procedure. Calling a procedure ------------------- CALL Transfers control to a BASIC SUB procedure, or to a procedure written in another programming language and compiled separately. (The CALL keyword is optional if a DECLARE statement is used.) Exiting from a procedure ------------------------ EXIT FUNCTION Provides an alternative way to exit a FUNCTION procedure. EXIT SUB Provides an alternative way to exit a SUB procedure. Declaring a reference to a procedure ------------------------------------ DECLARE Declares a FUNCTION or SUB procedure and, optionally, specifies the number and type of its parameters. Sharing variables among modules, procedures, or programs -------------------------------------------------------- COMMON Shares variables among separate modules. When used with the SHARED attribute, COMMON blocks share variables among different procedures in the same module. When used with a blank (unnamed) COMMON block, variables pass from current program to new program when control is transferred with the CHAIN statement. SHARED When used with the COMMON, DIM, or REDIM statement at the module level (for example, DIM SHARED), shares variables with every SUB or FUNCTION procedure in a single module. When used by itself within a procedure, shares variables between that procedure and the module-level code. Preserving variable values -------------------------- STATIC Forces variables to be local to a procedure or DEF FN function and preserves the value stored in the variable if the procedure or function is exited, then called again.